<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<script type="text/javascript">

// name space for this page
var p01_cworder = {
	mid: "${menuId}",
	focusId: "p01_cworder_orderDate"
};

// codition panel
p01_cworder.condPanel = Ext.create("Ext.form.Panel", {
	region: "north",
    buttonAlign: "left",
    frame: true,
    bodyPadding: 5,
    fieldDefaults: {
    	labelAlign: "left",
        labelWidth: 100,
        width: 240,
        labelStyle: "padding-left: 15px"
    },
    items: [{
        xtype: "fieldset",
    	title: "检索条件",
    	layout: "anchor",
        defaults: {
            padding: "2 0",
            anchor: "100%"
        },
        margin: "0",
    	items: [{
    	    xtype: "container",
            layout: "hbox",
            defaultType: "textfield",
            items: [{
            	id: "p01_cworder_orderDate",
               	xtype: "datefield",
                format: "Y-m-d",
                fieldLabel: "服务日期",
                name: "orderDate"
            }, {
                fieldLabel: "套餐",
                name: "svcPackage"
            }, {
            	xtype: "uXcombo",
                name: "status",
                comboOpts: {
                    comboId: crm.consts.CDD_CD0004
                },
                fieldLabel: "订单状态",
                labelWidth: 100,
                width: 240
            }]
        }, {
            xtype: "container",
            layout: "hbox",
            defaultType: "textfield",
            items: [ {
            	fieldLabel: "订单号",
                name: "order_id"
            }, {
            	fieldLabel: "车牌号码",
                name: "car_id"
            }, {
            	fieldLabel: "客户姓名",
                name: "name"
            } ]
        }]
    }],
    buttons: [{
        text: "查询",
        handler: function() {
        	p01_cworder.store.loadPage(1, {
        		params: p01_cworder.condPanel.getForm().getValues()
        	});
        }
    }, {
        text: "清空条件",
        handler: function() {
        	this.up("form").getForm().reset();
            Ext.getCmp(p01_cworder.focusId).focus();
        }
    }]
});



//Model -> CustInfo
Ext.define("p01_cworder_Order", {
	extend: "Ext.data.Model",
	fields: [
	    {name:"order_id", type:"string"},
	    {name:"mobile", type:"string"},
	    {name:"name", type:"string"},
	    {name:"gender", type:"string"},
	    {name:"gender_disp", type:"string"},
	    {name:"phone1", type:"string"},
	    {name:"phone2", type:"string"},
	    {name:"car_id", type:"string"},
	    {name:"car_size_type", type:"string"},
	    {name:"car_size_type_disp", type:"string"},
	    {name:"order_type", type:"string"},
	    {name:"order_type_disp", type:"string"},
	    {name:"order_date", type:"string"},
	    {name:"addr", type:"string"},
	    {name:"svc_package", type:"string"},
	    {name:"svc_package_disp", type:"string"},
	    {name:"total_fee", type:"string"},
	    {name:"pay_type", type:"string"},
	    {name:"pay_type_disp", type:"string"},
	    {name:"status", type:"string"},
	    {name:"status_disp", type:"string"},
	    {name:"pay_type_disp", type:"string"},
	    {name:"executor", type:"string"},
	    {name:"create_date", type:"string"}
	]
});

//store
p01_cworder.store = Ext.create("Ext.data.Store", {
	model: p01_cworder_Order,
	pageSize: 30,
	proxy: {
	    type: "ajax",
	    url: "cworder/query.shtm",
	    actionMethods: {
	        read: "POST"
	    },
	    reader: {
	        root: "cworders",
	        totalProperty: "totalCount"
	    },
	    simpleSortMode: true,
	    listeners: {
	        exception: function(proxy, resp, op, opts) {
	            var obj = Ext.JSON.decode(resp.responseText);
	            Ext.Msg.alert("信息提示", obj.errorMsgs);
	        }
	    }
	}
});

// grid panel
p01_cworder.gridPanel = Ext.create("Ext.grid.Panel", {
	region: "center",
	frame: true,
	margin:  0,
	autoScroll: true,
    store: p01_cworder.store,
    columns: [ {
            text: "操作",
            menuDisabled: true,
            sortable: false,
            xtype: "actioncolumn",
            width: 80,
            align: "center",
            items: [{
                icon: "images/icons/edit.png",
                tooltip: "编辑",
                handler: function(grid, rowIndex, colIndex) {
                    var rec = p01_cworder.store.getAt(rowIndex);
                    crm.utils.createTopTab({
                        id: p01_cworder.mid + "_edit",
                        name: "编辑订单信息(" + rec.get("order_id") + ")",
                        url: "show_cworder.shtm?module=modify",
                        qparams: {
                            orderId: rec.get("order_id")
                        }
                    });
                }
            }]
        },
        { text: "订单号", width: 120,  dataIndex: "order_id" },
        { text: "当前状态", width: 80, dataIndex: "status_disp"},
        { text: "姓名", width: 100, dataIndex: "name"},
        // { text: "性别", dataIndex: "gender_disp"},
        { text: "手机号码", width: 120, dataIndex: "mobile"},
        //{ text: "联系电话一", dataIndex: "phone1"},
        //{ text: "联系电话二", dataIndex: "phone2"},
        { text: "车牌号", width: 100, dataIndex: "car_id"},
        { text: "预约方式", width: 80, dataIndex: "order_type_disp"},
        { text: "车体类型", width: 80, dataIndex: "car_size_type_disp"},
        { text: "服务套餐", width: 100, dataIndex: "svc_package_disp"},
        { text: "合计费用", width: 80, dataIndex: "total_fee"},
        //{ text: "付款方式", dataIndex: "pay_type_disp"},
        { text: "服务预约时间", width: 180, dataIndex: "order_date"},
        { text: "服务地点", width: 400, dataIndex: "addr"}
    ],
    viewConfig: {
    	forceFit: true
    },
    autoScroll: true,
    bbar: Ext.create("Ext.PagingToolbar", {
        store: p01_cworder.store,
        displayInfo: true,
        displayMsg: "显示客户 {0} - {1} / {2}",
        emptyMsg: "无记录"
    })
});

// show
p01_cworder.items = [p01_cworder.condPanel, p01_cworder.gridPanel];
crm.utils.showTabContent(p01_cworder);

</script>

